package com.tiandao.mofang.core.util;

import com.tiandao.mofang.core.RobotSingleton;

import java.awt.*;
import java.awt.event.KeyEvent;

public class OpenBoxQHListener implements Runnable {
    public static Robot robot = RobotSingleton.getInstance();
    @Override
    public void run() {
        try {
            Thread.sleep(300000);
            if(OpenBox.HAO_NUM >= 2){
                Thread.sleep(300);
                robot.keyPress(KeyEvent.VK_ALT);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyRelease(KeyEvent.VK_ALT);
            }
            Thread.sleep(300000);
            if(OpenBox.HAO_NUM >= 3){
                Thread.sleep(300);
                robot.keyPress(KeyEvent.VK_ALT);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyRelease(KeyEvent.VK_ALT);
            }
            Thread.sleep(300000);
            if(OpenBox.HAO_NUM >= 4){
                Thread.sleep(300);
                robot.keyPress(KeyEvent.VK_ALT);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyRelease(KeyEvent.VK_ALT);
            }
            Thread.sleep(300000);
            if(OpenBox.HAO_NUM >= 5){
                Thread.sleep(300);
                robot.keyPress(KeyEvent.VK_ALT);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(200);
                robot.keyRelease(KeyEvent.VK_ALT);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
